﻿<ContextMenu x:Class="Adan.Client.Map.RoomContextMenu"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:Properties="clr-namespace:Adan.Client.Map.Properties"
             mc:Ignorable="d"
             d:DesignHeight="300"
             d:DesignWidth="300">
    <ContextMenu.Resources>
        <ResourceDictionary Source="Resources.xaml"/>
    </ContextMenu.Resources>
    <MenuItem Header="{x:Static  Properties:Resources.RoomIconContext}"
              ItemsSource="{StaticResource IconsList}">
        <MenuItem.ItemContainerStyle>
            <Style TargetType="MenuItem"
                   BasedOn="{StaticResource {x:Type MenuItem}}">
                <Setter Property="IsChecked">
                    <Setter.Value>
                        <MultiBinding Converter="{StaticResource equalityToBooleanConverter}">
                            <Binding  Mode="OneWay" />
                            <Binding RelativeSource="{RelativeSource FindAncestor,AncestorType={x:Type ContextMenu}}"
                                     Path="DataContext.Icon"
                                     Mode="OneWay" />
                        </MultiBinding>
                    </Setter.Value>
                </Setter>
                <EventSetter Event="Click"
                             Handler="HandleIconChange" />
            </Style>
        </MenuItem.ItemContainerStyle>
        <MenuItem.ItemTemplate>
            <DataTemplate>
                <Border Width="25"
                        Height="25"
                        CornerRadius="2"
                        BorderBrush="White"
                        BorderThickness="2"
                        HorizontalAlignment="Center"
                        Background="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ContextMenu}}, Path=DataContext.Color,Converter={StaticResource RoomColorToBrushConverter}}">
                    <Border Background="{Binding Converter={StaticResource RoomIconToBrushConverter}}" />
                </Border>
            </DataTemplate>
        </MenuItem.ItemTemplate>
    </MenuItem>
    <MenuItem Header="{x:Static  Properties:Resources.RoomColorContext}"
              ItemsSource="{StaticResource ColorsList}">
        <MenuItem.ItemContainerStyle>
            <Style TargetType="MenuItem"
                   BasedOn="{StaticResource {x:Type MenuItem}}">
                <Setter Property="IsChecked">
                    <Setter.Value>
                        <MultiBinding Converter="{StaticResource equalityToBooleanConverter}">
                            <Binding  Mode="OneWay"/>
                            <Binding RelativeSource="{RelativeSource FindAncestor,AncestorType={x:Type ContextMenu}}"
                                     Path="DataContext.Color"
                                     Mode="OneWay" />
                        </MultiBinding>
                    </Setter.Value>
                </Setter>
                <EventSetter Event="Click"
                             Handler="HandleColorChange" />
            </Style>
        </MenuItem.ItemContainerStyle>
        <MenuItem.ItemTemplate>
            <DataTemplate>
                <Border Width="25"
                        Height="25"
                        CornerRadius="2"
                        BorderBrush="White"
                        BorderThickness="2"
                        HorizontalAlignment="Center"
                        Background="{Binding Converter={StaticResource RoomColorToBrushConverter}}">
                </Border>
            </DataTemplate>
        </MenuItem.ItemTemplate>
    </MenuItem>

    <MenuItem Header="{x:Static  Properties:Resources.GotoThisRoom}" Click="HandleGotoRoom" />
    <MenuItem Header="{x:Static  Properties:Resources.Edit}" Click="HandleEditRoom"/>
</ContextMenu>
